﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QD.SQLHelper
{
    /// <summary>
    /// 数据库登录信息
    /// </summary>
    public class LogonConfig : ICloneable
    {
        /// <summary>
        /// 服务器名称
        /// </summary>
        public string ServerName { get; set; }

        /// <summary>
        /// 登录方式(1:Windows 身份证验  2:SQL Server 身份证验)
        /// </summary>
        public int LogonType { get; set; }
        public string UserID { get; set; }
        public string PassWord { get; set; }

        /// <summary>
        ///  取数据库的连接字符串
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public string GetConnectionStrings(string dbName)
        {
            string connStr = "";
            if (LogonType == 1)
            {
                connStr = "Data Source=" + ServerName + ";Initial Catalog=" + dbName + ";Integrated Security=true;persist security info=true";
            }
            else
            {
                connStr = "Data Source=" + ServerName + ";User ID=" + UserID + ";Password=" + PassWord + ";Initial Catalog=" + dbName + ";persist security info=true";
            }

            return connStr;
        }

        public object Clone()
        {
            return this.MemberwiseClone();
        }
    }
}
